package com.jumi.microservice.service;

import com.alibaba.fastjson.JSON;
import com.jumi.microservice.dto.PayNotifyRequest;
import com.jumi.microservice.dto.PayNotifyResponse;
import com.jumi.microservice.interfaces.BasePayment;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author scw
 * @date 2020/10/31
 */
@DubboService(cluster = "failfast", timeout = 5000)
public class PayCoreServiceImpl implements IPayCoreService {

    private static final Logger log = LoggerFactory.getLogger(PayCoreServiceImpl.class);

    @Override
    public PayNotifyResponse paymentNotify(PayNotifyRequest request) {
        log.info("支付回调参数：[{}]", JSON.toJSONString(request));
        PayNotifyResponse payNotifyResponse = (PayNotifyResponse) BasePayment.paymentMap.get(request.getPayChannel()).completePayment(request);
        return payNotifyResponse;
    }
}
